﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace SwanEngine.Astar
{
    /// <summary>
    /// 格子数据
    /// </summary>
    public class GridNodeVO
    {
        public const int Walk = 1 << 0;
        public const int Safe = 1 << 1;

        public GameObject go;

        public int x;

        public int z;

        public float y;
        /// <summary>
        /// 是否可走
        /// </summary>
        public bool isWalkable = true;
        /// <summary>
        /// 安全区域
        /// </summary>
        public bool isSafe = false;

        public GridNodeVO(int x, int z, bool isWalkable = true)
        {
            this.x = x;
            this.z = z;
            this.isWalkable = isWalkable;
        }

        public byte GetStatusBit()
        {
            int val = 0;
            if (isWalkable)
            {
                val = val | Walk;
            }
            if(isSafe)
            {
                val = val | Safe;
            }
            return (byte)val;
        }

        public void SetStatusBit(byte val)
        {
            isWalkable = (val & Walk) != 0;

            isSafe = (val & Safe) != 0;
        }
    }
}
